package com.lsus.golkhadi.client.viewsImpl;

import com.allen_sauer.gwt.dnd.client.DragContext;
import com.allen_sauer.gwt.dnd.client.drop.SimpleDropController;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class SetWidgetOnTableDropController extends SimpleDropController {

		private final CenterTable dropTarget;
		private final HorizontalPanel source;//later to be got from library
		
		public SetWidgetOnTableDropController(CenterTable dropTarget, HorizontalPanel source) {
		    super(dropTarget);
		    this.dropTarget = dropTarget;
		    this.source = source;
		}

		@Override
		public void onDrop(DragContext context) {
		    if (dropTarget.showCard((CardImage)context.draggable, LoginPanel.player.getPosition())){
		    	super.onDrop(context);
		    }
		    else{
		    	//restore
		    	source.add((CardImage)context.draggable);
		    }
		}
}
